/*
 * Copyright (c) 2018 - 2019. www.vtuzx.com Inc. All Rights Reserved
 */

package com.vtuzx.kingdee.xqc_api.web;

import com.vtuzx.core.bean.dto.VtuzxToken;
import com.vtuzx.core.utils.VtuzxUtil;
import com.vtuzx.kingdee.xqc_api.service.IXqcHistoryService;
import com.vtuzx.web.validator.VtuzxValidator;
import com.vtuzx.web.web.VtuzxApi;
import com.vtuzx.web.web.VtuzxControlParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 接口调用履历相关接口
 */
@RequestMapping("/${vtuzx.fast.api.path}/${vtuzx.fast.api.version}/api_history/")
@RestController
public class XqcHistoryController {

    /** 接口调用履历服务 */
    @Autowired
    private IXqcHistoryService historyService;

    /**
     * 重推
     */
    @PostMapping("/retry")
    @VtuzxApi( fields = { @VtuzxValidator(key = "id", label = "履历ID", notNull = true, objectId = true) } )
    public Object retry(@VtuzxControlParam VtuzxToken token, @RequestBody Map<String, Object> p) throws Exception {
        String id = VtuzxUtil.getString(p, "id");
        historyService.retry(token, id);
        return null;
    }

    /**
     * 获取接口调用履历列表
     */
    @PostMapping("/get_sync_history_list")
    @VtuzxApi
    public Object getSyncHistoryList(@VtuzxControlParam VtuzxToken token, @RequestBody Map<String, Object> p) {
        return historyService.getHistoryList(token, p);
    }

    /**
     * 获取接口调用履历列表
     */
    @PostMapping("/get_operation_history_list")
    @VtuzxApi
    public Object getOperationHistoryList(@VtuzxControlParam VtuzxToken token, @RequestBody Map<String, Object> p) {
        return historyService.getOperationHistoryList(token, p);
    }
}
